const App = {
    mixins: [Query],//配置文件，路径/utils/mixins.js
    data() {
        return {
            page: {
                activeName:'first',
                value1:'',
                value2:'',
                PageNumber: 1, //页码
                RowAmount: 10,
                Condition: window.btoa(unescape(encodeURIComponent("%%,%%")))

            },
            type1:[],
            str1:''
        }
    },
    mounted() {
        this.getData();
    },
    methods: {
        check(){
            this.page.Condition = window.btoa(unescape(encodeURIComponent("%" + this.page.value1 + "%,%" + (this.page.value2 ? this.page.value2 : '') + "%")));
            this.postgetList(this.page)
        },
        handleClick() {
            if (this.page.activeName == 'first') {
                this.str1 = '';
            } else if (this.page.activeName == 'second') {
                this.str1 = "\r\nAND IFNULL(comments.Public_Datetime,'') = ''";
            } else if (this.page.activeName == 'third') {
                this.str1 = "\r\nAND IFNULL(comments.Public_Datetime,'') <> ''";
            }
            this.page.ExtensionCondition = window.btoa(unescape(encodeURIComponent(this.str1)));
            this.postgetList(this.page)
        },
        getData() {
            $.ajax({
              headers: requestHeaders(),
              url: `${mh}/generalBusiness/generalQueryByTableName`,
              method: "post",
              data: {
                Data: 'list_management',
                Condition: `Row_Status <> '1'`,
              },
              success: (res) => {
                this.type1 = res;
              },
              complete: (XMLHttpRequest) => {
                requestPretreatment(XMLHttpRequest)
              },
            });
          },
        Treedata() {
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryByTableName`,
                type: "POST",
                data: {
                    Data: "merchant",
                    Condition: "Row_Status='0'",
                },
                success: (data) => {
                    $.ajax({
                        headers: requestHeaders(),
                        url: `${mh}/generalBusiness/generalQueryBySQLSerialNumber`,
                        method: "post",
                        data: {
                            SQLSerialNumber: 'f_merchant_business_mapping_blue_plate3',
                            Condition: '',
                            ExtensionCondition: '',
                        },
                        success: (data1) => {
                            let treeData = [];
                            data.forEach(item => {
                                let arr = data1.filter(i => i.Merchant_SerialNumber == item.Merchant_SerialNumber)
                                if (arr.length > 0) {
                                    let children = [];
                                    arr.forEach(obj => {
                                        children.push({
                                            id: obj.Merchant_Mapping_Blue_Plate_SerialNumber,
                                            Merchant_Category_SerialNumber: obj.Merchant_Category_SerialNumber,
                                            Blue_Plate_SerialNumber: obj.Blue_Plate_SerialNumber,
                                            name: obj.Merchant_Alias,
                                        })
                                    });
                                    treeData.push({
                                        id: item.Merchant_SerialNumber,
                                        name: item.Merchant_Name,
                                        children,
                                    })
                                }
                            });
                            this.treeData = treeData;
                            // this.handleNodeClick(treeData[0].children[0], {level:2})
                        },
                        complete: (XMLHttpRequest) => {
                            requestPretreatment(XMLHttpRequest);
                        },
                        dataType: "json",
                    });
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            });
        },
        handleNodeClick(data, node) {
            this.page.value2 = data.id;
            if (node.level == 1) {
                // this.page.Condition = window.btoa(unescape(encodeURIComponent("%" + this.page.value2 + "%")));
            } else if (node.level == 2) {
                this.page.Condition = window.btoa(unescape(encodeURIComponent("%" + this.page.value2 + "%")));
                // this.page.Condition = window.btoa(unescape(encodeURIComponent("%%,%" + this.page.value1 + "%,%" + this.page.value2 + "%,%%")));
            }
            this.postgetList(this.page)
        },
        handleAdd(row){
            window.location.href = './add.html?action=Add&nodeKey=' + row.Merchant_Category_SerialNumber
        },
    },
};

const { createApp } = Vue;
const app = createApp(App);
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
const ElMessage = ElementPlus.ElMessage;
app.use(ElementPlus, { locale: zhCn });
app.mount("#app");
